import api from '../utils/axios'
import qs from 'qs'

export default {

    /*  密码登录  */
    login: function ({phone = '',password=''}) {
      return api.post('/api/block/loginPass', {phone,password}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },

    /*  发送短信  */
    sendCodeForRegister: function ({phone = '',smsType='0001'}) {
      //0001代表注册，00002代表修改密码
      return api.post('/api/block/sendCode', {phone,smsType}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },

    /*  发送短信  */
    sendCodeForLogin: function ({phone = '',smsType='0002'}) {
      //0001代表注册，00002代表修改密码
      return api.post('/api/block/sendCode', {phone,smsType}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },

    /*  发送短信  */
    sendCodeForForgetPwd: function ({phone = '',smsType='0003'}) {
      //0001代表注册，00002代表修改密码
      return api.post('/api/block/sendCode', {phone,smsType}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },
    /*  发送短信  */
  sendCodeForResetPayPwd: function ({phone = '',smsType='0005'}) {
      //0001代表注册，00002代表修改密码
      return api.post('/api/block/sendCode', {phone,smsType}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },

    /*  短信登录  */
  loginCode: function ({phone = '',code=''}) {
      return api.post('/api/block/loginCode', {phone,code}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },
    /*  用户注册  */
  userReg: function ({phone='',code = '',password='',inviteCode=''}) {
      return api.post('/api/block/userReg', {phone,code,password,inviteCode}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },
    /*  忘记密码 newPwd需要MD5加密  */
  modifyPwdWithMd5: function ({newPwd='',mobile = '',captcha=''}) {
      return api.post('/api/block/modifyPwd', {newPwd,mobile,captcha}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },

    /*  设置/修改密码 newPwd不需要MD5加密  */
  modifyPwdWithoutMd5: function ({newPwd='',mobile = '',captcha=''}) {
      return api.post('/api/block/modifyPwd', {newPwd,mobile,captcha}).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },

    /*  设置/修改密码 newPwd不需要MD5加密  */
  logout: function ({}) {
      return api.get('/api/block/logout', qs.stringify({})).then((resp) => {
            return Promise.resolve(resp.data)
        })
    },



}
